'use strict'
const keys = require('./key')

module.exports = appInfo => {

    const config = exports = {
        security:{
            csrf:false
        },
        cors:{
            origin:'*',
            allowMethods:'GET,HEAD,PUT,POST,DELETE,PATCH'
        },
        mongoose:{
            client:{
                url:'mongodb://localhost:27017/zhihu',options:{ useUnifiedTopology:true,useFindAndModify:false }
            }
        },
        bodyParser:{
            jsonLimit:'1mb',
            formLimit:'1mb'
        },
        jwt:{
            secret:'wcnmlgb666'
        },
        io:{
            init:{},
            namespace:{
                '/':{
                    connectionMiddleware:['NoticeConnection'],
                    packetMiddleware:[]
                }
            }
        },
        redis:{
            client:{
                port:6379,
                host:'127.0.0.1',
                password:'',
                db:0
            }
        }
    }


    config.keys = appInfo.name + '_sujie5201314'


    const userConfig = {
        qiniu_accessKey:keys.qiniu_accessKey,
        qiniu_secretKey:keys.qiniu_secretKey,
        qiniu_bucket:keys.qiniu_bucket
    }


    return {
        ...config,
        ...userConfig
    }
}
